//-------------------------------------------------------------------------------
/// class CBatchMemoryAllocator : allocate memory once and give them to anywhere
/// randomly. destroy the memory at last in one time.
//--------------------------------------------------------------------------------


class CBatchMemoryAllocator
{
public:
	CBatchMemoryAllocator(void);
	~CBatchMemoryAllocator(void);

	// set the size for allocating again if remaining memory not enough.
	void SetAllocateBlockSize(const int size);
	// process allocate request.
	void* Allocate(const int size);
	// destroy this class.
	void Destroy(void);

protected:
	struct block
	{
		unsigned int size;
		unsigned int used;
		unsigned int next;
		char* data[];
	};

	block *m_pBlocks;
	int m_iNextBlockSize;
};